﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _45里氏转换的练习
{
    class Program
    {
        static void Main(string[] args)
        {
            ShiJie[] s = new ShiJie[10];
            Random r = new Random();
            for (int i = 0; i < s.Length; i++)
            {
                int rNum = r.Next(1, 7);
                switch (rNum)
                {
                    case 1: s[i] = new RenLei();
                        break;
                    case 2: s[i] = new LaoSi();
                        break;
                    case 3: s[i] = new XueSheng();
                        break;
                    case 4: s[i] = new DongWu();
                        break;
                    case 5: s[i] = new ZhiWu();
                        break;
                    case 6: s[i] = new ShiJie();
                        break;
                }
            }
            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] is RenLei)
                {
                    ((RenLei)s[i]).Ren();
                }else if (s[i] is LaoSi)
                {
                    ((LaoSi)s[i]).Lao();
                }else if (s[i] is XueSheng)
                {
                    ((XueSheng)s[i]).xue();
                }else if(s[i] is )                
            }

            Console.ReadKey();
        }

        public class ShiJie
        {
            public void Shi()
            {
                Console.WriteLine("世界");
            }
        }

        public class RenLei : ShiJie
        {
            public void Ren()
            {
                Console.WriteLine("人类");
            }
        }

        public class LaoSi :ShiJie
        {
            public void Lao()
            {
                Console.WriteLine("老师");
            }
        }
        
        public class XueSheng : ShiJie 
        {
            public void xue()
            {
                Console.WriteLine("学生");
            }
        }

        public class DongWu : ShiJie
        {
            public void Dong()
            {
                Console.WriteLine("动物");
            }
        }

        public class ZhiWu : ShiJie
        {
            public void Zhi()
            {
                Console.WriteLine("植物");
            }
        }
    }
}
